package com.qos.fun;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class IncomingHandler extends Handler {
    private static final String LOG = "incominghandler";
    private Activity ctx;
    
    public IncomingHandler(Activity activity) {
        ctx = activity;
    }
    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case ConnectManager.MSG_LOGIN:
                if(msg.arg1 == 0) {
                    Log.d(LOG, "Succe");
                    Intent intent = new Intent(ctx, QosActivity.class);
                    ctx.startActivity(intent);
                    ctx.finish();
                } else {
                    Log.d(LOG,"client register");
                }
                break;
            case ConnectManager.MSG_REGIST:
                if(msg.arg1 == 0) {
                    Log.d(LOG, "Succe");
                    Intent intent = new Intent(ctx, MainActivity.class);
                    ctx.startActivity(intent);
                    ctx.finish();
                } else {
                    Log.d(LOG,"client register");
                }
                break;
    
            case ConnectManager.MSG_LOGOUT:
                Intent intent = new Intent(ctx, MainActivity.class);
                ctx.startActivity(intent);
                ctx.finish();
                break;
            default:
                super.handleMessage(msg);
        }
    }
}
